package com.qf.index;

import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ZipUtil;
import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import cn.hutool.json.JSONUtil;
import lombok.Data;

import java.io.Serializable;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * NCBI文本格式的解析程序，共计87个字段，可以调用getTextList(String html, Set<String> fieldSet)方法，参数包括两个，一个是路径或文本，一个是字段名称的集合(Set<String> fieldSet)，返回的是一个List<Text> textList。
 * 贾新志 2025.02.17
 * 部分pm的数据作者信息为空，比如：PMID: 40117432
 * 此时字段auList内的作者为空，改用字段cnList：
 * ["Association of Women’s Health, Obstetric and Neonatal Nurses"]
 * 因我在处理时不需要作者信息，仅在福磊显示时才需要，所以需要福磊来修改。2025.04.12
 */

public class NcbiText {


    public static void main(String[] args) throws SQLException {
        String newDataName = "html.";
        String textFormatTable = newDataName + "text_format_add_pmid";
        String ncTextTable = newDataName + "nc_text_table_0418";
        String ncOldTextTable = newDataName + "nc_text_table_0320";
        // 下面的方法，考查的是Text格式的就有哪些字段，以及哪些字段是多条内容（比如，主题词MH就是多条的），哪些是单条的（比如，PMID号就是单条的），用于建实体类以及建表，之后就可以不用了，除非再次大规模跑数据。
//        fieldNumber();

        // 有美国VPS上跑时是分为6张表的，所以需要对每张表跑一次。
        String textFormatTable0 = newDataName + "text_format_down_pmid_0";
        String textFormatTable1 = newDataName + "text_format_down_pmid_1";
        String textFormatTable2 = newDataName + "text_format_down_pmid_2";
        String textFormatTable3 = newDataName + "text_format_down_pmid_3";
        String textFormatTable4 = newDataName + "text_format_down_pmid_4";

        Set<Integer> pmIdSet = new HashSet<>();
        Db.use().execute("truncate table " + ncTextTable);
        // 将多个textFormatTable表合并进ncTextTable表。
        updateTextFormatTable(textFormatTable, "id", "html", ncTextTable, pmIdSet);
//        updateTextFormatTable(textFormatTable0, "id", "html", ncTextTable, pmIdSet);
//        updateTextFormatTable(textFormatTable1, "id", "html", ncTextTable, pmIdSet);
//        updateTextFormatTable(textFormatTable2, "id", "html", ncTextTable, pmIdSet);
//        updateTextFormatTable(textFormatTable3, "id", "html", ncTextTable, pmIdSet);
//        updateTextFormatTable(textFormatTable4, "id", "html", ncTextTable, pmIdSet);

//        allPmIdSet(ncTextTable, "id", "pmid", pmIdSet);
//        String textFormatTable5 = newDataName + "text_format_add_pmid_10";
//        System.out.println("pmIdSet.size(): " + pmIdSet.size());
//        updateTextFormatTable(textFormatTable5, "id", "html", ncTextTable, pmIdSet);

        updateAllTable(ncOldTextTable, "id", "pmid", ncTextTable, pmIdSet);

    }

    // 把老的ncOldTextTable表合并进来，形成最终的总表ncTextTable
    public static void updateAllTable(String ncOldTextTable, String autoId, String field, String ncTextTable, Set<Integer> pmIdSet) throws SQLException {
        String save = "`aidList`,`mhList`,`isList`,`ptList`,`rnList`,`otList`,`laList`,`plList`,`lidList`,`grList`,`siList`,`oidList`,`conList`,`cinList`,`cnList`,`einList`,`gnList`,`iradList`,`efrList`,`gsList`,`pbList`,`uofList`,`uinList`,`rofList`,`rinList`,`sfmList`,`isbnList`,`rpfList`,`rpiList`,`ecfList`,`eciList`,`crfList`,`criList`,`oriList`,`spinList`,`drinList`,`ddinList`,`rrfList`,`auList`,`phstList`,`stat`,`dp`,`crdt`,`edat`,`ti`,`so`,`jt`,`pst`,`jid`,`lr`,`own`,`mhda`,`ta`,`pmid`,`vi`,`pg`,`dcom`,`ip`,`sb`,`ab`,`dep`,`oto`,`pmc`,`pmcr`,`ci`,`cois`,`ir`,`fir`,`tt`,`rf`,`mid`,`fps`,`ps`,`oab`,`oabl`,`fed`,`ed`,`bti`,`ctdt`,`cti`,`cp`,`drdt`,`en`,`rriList`";
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        int onePageNum = 1000;
        int tableMax = Db.use().queryNumber("select max(" + autoId + ") from " + ncOldTextTable).intValue();
        if (tableMax > 0) {
            Collection<Integer> tableList = new ArrayList<>();
            NumberUtil.appendRange(0, tableMax + onePageNum, onePageNum, tableList);
            tableList.parallelStream().forEach(startId -> {
                try {
                    List<Entity> tableData = Db.use().query("select `" + autoId + "`,`" + field + "` from " + ncOldTextTable + " where " + autoId + " between " + startId + " and " + (startId + onePageNum - 1));
                    System.out.println("\033[31;1m" + format.format(new Date()) + " 读表现在开始：" + startId + " 表名：" + ncOldTextTable + Utils.printMemoryStr() + "\033[0m");
                    for (Entity entry : tableData) {
                        Integer pmId = entry.getInt("pmid");
                        Integer id = entry.getInt(autoId);
                        if (null != pmId && pmId > 0 && !pmIdSet.contains(pmId) && null != id && id > 0) {
                            // insert into pm_ut_aid_info_1w (`c1_list`, `rp_list`, `pmId`) SELECT `c1_list`, `rp_list`, 100 from pm_ut_aid_info where id =1;
                            try {
                                Db.use().execute("insert into " + ncTextTable + "(" + save + ") SELECT " + save + " from " + ncOldTextTable + " where id = " + id + ";");
                                pmIdSet.add(pmId);
                            } catch (SQLException e) {
                                throw new RuntimeException(e);
                            }
                        }
                    }
                } catch (SQLException e) {
                    throw new RuntimeException(e);
                }
            });
        }
    }

    public static void allPmIdSet(String ncTextTable, String autoId, String field, Set<Integer> pmIdSet) throws SQLException {
        int onePageNum = 1000;
        int tableMax = Db.use().queryNumber("select max(" + autoId + ") from " + ncTextTable).intValue();
        if (tableMax > 0) {
            Collection<Integer> tableList = new ArrayList<>();
            NumberUtil.appendRange(0, tableMax + onePageNum, onePageNum, tableList);
            for (Integer startId : tableList) {
                List<Entity> tableData = Db.use().query("select `" + autoId + "`,`" + field + "` from " + ncTextTable + " where " + autoId + " between " + startId + " and " + (startId + onePageNum - 1));
                for (Entity entry : tableData) {
                    Integer pmId = entry.getInt("pmid");
                    if (null != pmId && pmId > 0) {
                        pmIdSet.add(pmId);
                    }
                }
            }
        }
    }

    public static List<Text> getTextList(String html, Set<String> fieldSet) {
        if (html == null || (!html.endsWith(".txt") && !html.contains("PMID- "))) {
            return new ArrayList<>();
        }
//        List<String> split = FileUtil.readLines(html, "utf-8");
        // 如里html为路径文件，比如，String path = "E:\\MySQL\\data\\html\\html_2pcs.txt"，使用上面的语句，分隔为一句一行，如果html为抓取程序返回的String类型的文本数据，则使用下面的语句用回车符分隔为一句一行。fieldSet是实际的字段的集合。
        String[] split = html.split(System.lineSeparator());
        String name = "";
        boolean bool = false;
        List<Text> textList = new ArrayList<>();
        Text text = new Text();
        List<AU> auList = new ArrayList<>();
        AU au = new AU();
        for (String s : split) {
            s = Pattern.compile("PMID- [1-9]").matcher(s).find() ? s.substring(s.indexOf("PMID- ")) : s;
            if (s.startsWith("PMID- ") && NumberUtil.isInteger(s.substring("PMID- ".length()).trim())) {
                if (text.getPmid() > 0) {
                    if (!au.getFau().isEmpty() || !au.getAu().isEmpty() || !au.getAuid().isEmpty() || !au.getAdList().isEmpty()) {
                        auList.add(au);
                    }
                    text.setAuList(auList);
                    textList.add(text);
                }
                text = new Text();
                auList = new ArrayList<>();
                au = new AU();
                text.setPmid(Integer.parseInt(s.substring("PMID- ".length()).trim()));
                name = "PMID- ";
                bool = true;
            }
            if (("</pre>".equals(s.trim()) || "</main>".equals(s.trim()) || "</body>".equals(s.trim()) || "</html>".equals(s.trim())) || (s.contains("</pre>") && s.contains("</main>") && s.contains("</body>") && s.contains("</html>"))) {
                bool = false;
            }
            if (s.startsWith("FAU - ")) {
                if (!au.getFau().isEmpty() || !au.getAu().isEmpty() || !au.getAuid().isEmpty() || !au.getAdList().isEmpty()) {
                    auList.add(au);
                    au = new AU();
                }
                name = "FAU - ";
                au.setFau(s.substring(6).trim());
            }
            if (s.startsWith("AU  - ")) {
                name = "AU  - ";
                au.setAu(s.substring(6).trim());
            }
            if (s.startsWith("AUID- ")) {
                name = "AUID- ";
                au.setAuid(s.substring(6).trim());
            }
            if (s.startsWith("AD  - ")) {
                name = "AD  - ";
                au.getAdList().add(s.substring(6).trim());
            }
            if (bool && !name.isEmpty() && !s.isEmpty() && !Pattern.compile("^[A-Z]{2}[A-Z ]{2}- ").matcher(s).find() && s.startsWith(" ")) {
                if ("FAU - ".equals(name)) {
                    au.setFau(au.getFau() + " " + s.trim());
                }
                if ("AU  - ".equals(name)) {
                    au.setAu(au.getAu() + " " + s.trim());
                }
                if ("AUID- ".equals(name)) {
                    au.setAuid(au.getAuid() + " " + s.trim());
                }
                if ("AD  - ".equals(name)) {
                    au.setAdList(setLastList(au.getAdList(), s));
                }
            }
            name = setText(s, fieldSet, text, name, bool);
        }
        if (text.getPmid() > 0) {
            if (!au.getFau().isEmpty() || !au.getAu().isEmpty() || !au.getAuid().isEmpty() || !au.getAdList().isEmpty()) {
                auList.add(au);
            }
            text.setAuList(auList);
            textList.add(text);
        }
        return textList;
    }

    public static void updateTextFormatTable(String textFormatTable, String autoId, String field, String ncTextTable, Set<Integer> pmIdSet) throws SQLException {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        int onePageNum = 1000;
        Set<String> fieldSet = fieldSet();
        int tableMax = Db.use().queryNumber("select max(" + autoId + ") from " + textFormatTable).intValue();
        if (tableMax > 0) {
            Collection<Integer> tableList = new ArrayList<>();
            NumberUtil.appendRange(0, tableMax + onePageNum, onePageNum, tableList);
            for (Integer startId : tableList) {
                List<Entity> tableData = Db.use().query("select `" + autoId + "`,`" + field + "` from " + textFormatTable + " where " + autoId + " between " + startId + " and " + (startId + onePageNum - 1));
                System.out.println("\033[31;1m" + format.format(new Date()) + " 读表现在开始：" + startId + " 表名：" + textFormatTable + Utils.printMemoryStr() + "\033[0m");
                for (Entity entry : tableData) {
                    byte[] bytes = entry.getBytes("html");
                    Integer id = entry.getInt(autoId);
                    if (null != bytes && bytes.length > 0 && null != id && id > 0) {
                        String str = ZipUtil.unGzip(bytes, "utf-8");
                        List<Text> textList = getTextList(str, fieldSet);
                        insertNcTextTable(ncTextTable, textList, pmIdSet);
                        try {
                            Db.use().update(Entity.create().set("text_table_sum", textList.size()), Entity.create(textFormatTable).set(autoId, id));
                        } catch (SQLException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    }

    public static List<String> setLastList(List<String> list, String value) {
        List<String> result = new ArrayList<>(list);
        if (result.isEmpty()) {
            result.add(value.trim());
        } else {
            int last = result.size() - 1;
            result.set(last, (result.get(last) + " " + value.trim()).replaceAll(" +", " "));
        }
        return result;
    }

    public static String setText(String s, Set<String> fieldSet, Text text, String name, boolean bool) {
        if (Pattern.compile("^[A-Z]{2}[A-Z ]{2}- ").matcher(s).find()) {
            String field = s.substring(0, 6);
            name = field;
            String value = s.substring(6).trim();
            if (fieldSet.contains(field)) {
                if ("PHST- ".equals(field)) {
                    if (value.contains("[revised]")) {
                        text.getPhst().setRevised(value.substring(0, value.indexOf("[revised]")));
                    }
                    if (value.contains("[pubmed]")) {
                        text.getPhst().setPubmed(value.substring(0, value.indexOf("[pubmed]")));
                    }
                    if (value.contains("[ecollection]")) {
                        text.getPhst().setEcollection(value.substring(0, value.indexOf("[ecollection]")));
                    }
                    if (value.contains("[aheadofprint]")) {
                        text.getPhst().setAheadofprint(value.substring(0, value.indexOf("[aheadofprint]")));
                    }
                    if (value.contains("[accepted]")) {
                        text.getPhst().setAccepted(value.substring(0, value.indexOf("[accepted]")));
                    }
                    if (value.contains("[received]")) {
                        text.getPhst().setReceived(value.substring(0, value.indexOf("[received]")));
                    }
                    if (value.contains("[retracted]")) {
                        text.getPhst().setRetracted(value.substring(0, value.indexOf("[retracted]")));
                    }
                    if (value.contains("[medline]")) {
                        text.getPhst().setMedline(value.substring(0, value.indexOf("[medline]")));
                    }
                    if (value.contains("[entrez]")) {
                        text.getPhst().setEntrez(value.substring(0, value.indexOf("[entrez]")));
                    }
                    if (value.contains("[pmc-release]")) {
                        text.getPhst().setPmcRelease(value.substring(0, value.indexOf("[pmc-release]")));
                    }
                }
                if ("AID - ".equals(field)) {
                    text.getAidList().add(value);
                }
                if ("MH  - ".equals(field)) {
                    text.getMhList().add(value);
                }
                if ("IS  - ".equals(field)) {
                    text.getIsList().add(value);
                }
                if ("PT  - ".equals(field)) {
                    text.getPtList().add(value);
                }
                if ("RN  - ".equals(field)) {
                    text.getRnList().add(value);
                }
                if ("OT  - ".equals(field)) {
                    text.getOtList().add(value);
                }
                if ("LA  - ".equals(field)) {
                    text.getLaList().add(value);
                }
                if ("PL  - ".equals(field)) {
                    text.getPlList().add(value);
                }
                if ("LID - ".equals(field)) {
                    text.getLidList().add(value);
                }
                if ("GR  - ".equals(field)) {
                    text.getGrList().add(value);
                }
                if ("SI  - ".equals(field)) {
                    text.getSiList().add(value);
                }
                if ("OID - ".equals(field)) {
                    text.getOidList().add(value);
                }
                if ("CON - ".equals(field)) {
                    text.getConList().add(value);
                }
                if ("CIN - ".equals(field)) {
                    text.getCinList().add(value);
                }
                if ("CN  - ".equals(field)) {
                    text.getCnList().add(value);
                }
                if ("EIN - ".equals(field)) {
                    text.getEinList().add(value);
                }
                if ("GN  - ".equals(field)) {
                    text.getGnList().add(value);
                }
                if ("IRAD- ".equals(field)) {
                    text.getIradList().add(value);
                }
                if ("EFR - ".equals(field)) {
                    text.getEfrList().add(value);
                }
                if ("GS  - ".equals(field)) {
                    text.getGsList().add(value);
                }
                if ("PB  - ".equals(field)) {
                    text.getPbList().add(value);
                }
                if ("UOF - ".equals(field)) {
                    text.getUofList().add(value);
                }
                if ("UIN - ".equals(field)) {
                    text.getUinList().add(value);
                }
                if ("ROF - ".equals(field)) {
                    text.getRofList().add(value);
                }
                if ("RIN - ".equals(field)) {
                    text.getRinList().add(value);
                }
                if ("SFM - ".equals(field)) {
                    text.getSfmList().add(value);
                }
                if ("ISBN- ".equals(field)) {
                    text.getIsbnList().add(value);
                }
                if ("RPF - ".equals(field)) {
                    text.getRpfList().add(value);
                }
                if ("RPI - ".equals(field)) {
                    text.getRpiList().add(value);
                }
                if ("ECF - ".equals(field)) {
                    text.getEcfList().add(value);
                }
                if ("ECI - ".equals(field)) {
                    text.getEciList().add(value);
                }
                if ("CRF - ".equals(field)) {
                    text.getCrfList().add(value);
                }
                if ("CRI - ".equals(field)) {
                    text.getCriList().add(value);
                }
                if ("ORI - ".equals(field)) {
                    text.getOriList().add(value);
                }
                if ("SPIN- ".equals(field)) {
                    text.getSpinList().add(value);
                }
                if ("DRIN- ".equals(field)) {
                    text.getDrinList().add(value);
                }
                if ("DDIN- ".equals(field)) {
                    text.getDdinList().add(value);
                }
                if ("RRF - ".equals(field)) {
                    text.getRrfList().add(value);
                }
                if ("STAT- ".equals(field)) {
                    text.setStat(value);
                }
                if ("DP  - ".equals(field)) {
                    text.setDp(value);
                }
                if ("CRDT- ".equals(field)) {
                    text.setCrdt(value);
                }
                if ("EDAT- ".equals(field)) {
                    text.setEdat(value);
                }
                if ("TI  - ".equals(field)) {
                    text.setTi(value);
                }
                if ("SO  - ".equals(field)) {
                    text.setSo(value);
                }
                if ("JT  - ".equals(field)) {
                    text.setJt(value);
                }
                if ("PST - ".equals(field)) {
                    text.setPst(value);
                }
                if ("JID - ".equals(field)) {
                    text.setJid(value);
                }
                if ("LR  - ".equals(field)) {
                    text.setLr(value);
                }
                if ("OWN - ".equals(field)) {
                    text.setOwn(value);
                }
                if ("MHDA- ".equals(field)) {
                    text.setMhda(value);
                }
                if ("TA  - ".equals(field)) {
                    text.setTa(value);
                }
                if ("VI  - ".equals(field)) {
                    text.setVi(value);
                }
                if ("PG  - ".equals(field)) {
                    text.setPg(value);
                }
                if ("DCOM- ".equals(field)) {
                    text.setDcom(value);
                }
                if ("IP  - ".equals(field)) {
                    text.setIp(value);
                }
                if ("SB  - ".equals(field)) {
                    text.setSb(value);
                }
                if ("AB  - ".equals(field)) {
                    text.setAb(value);
                }
                if ("DEP - ".equals(field)) {
                    text.setDep(value);
                }
                if ("OTO - ".equals(field)) {
                    text.setOto(value);
                }
                if ("PMC - ".equals(field)) {
                    text.setPmc(value);
                }
                if ("PMCR- ".equals(field)) {
                    text.setPmcr(value);
                }
                if ("CI  - ".equals(field)) {
                    text.setCi(value);
                }
                if ("COIS- ".equals(field)) {
                    text.setCois(value);
                }
                if ("IR  - ".equals(field)) {
                    text.setIr(value);
                }
                if ("FIR - ".equals(field)) {
                    text.setFir(value);
                }
                if ("TT  - ".equals(field)) {
                    text.setTt(value);
                }
                if ("RF  - ".equals(field)) {
                    text.setRf(value);
                }
                if ("MID - ".equals(field)) {
                    text.setMid(value);
                }
                if ("FPS - ".equals(field)) {
                    text.setFps(value);
                }
                if ("PS  - ".equals(field)) {
                    text.setPs(value);
                }
                if ("OAB - ".equals(field)) {
                    text.setOab(value);
                }
                if ("OABL- ".equals(field)) {
                    text.setOabl(value);
                }
                if ("FED - ".equals(field)) {
                    text.setFed(value);
                }
                if ("ED  - ".equals(field)) {
                    text.setEd(value);
                }
                if ("BTI - ".equals(field)) {
                    text.setBti(value);
                }
                if ("CTDT- ".equals(field)) {
                    text.setCtdt(value);
                }
                if ("CTI - ".equals(field)) {
                    text.setCti(value);
                }
                if ("CP  - ".equals(field)) {
                    text.setCp(value);
                }
                if ("DRDT- ".equals(field)) {
                    text.setDrdt(value);
                }
                if ("EN  - ".equals(field)) {
                    text.setEn(value);
                }
                if ("RRI - ".equals(field)) {
                    text.getRriList().add(value);
                }
            }
        } else if (bool && !name.isEmpty() && !s.isEmpty()) {
            if ("AID - ".equals(name)) {
                text.setAidList(setLastList(text.getAidList(), s));
            }
            if ("MH  - ".equals(name)) {
                text.setMhList(setLastList(text.getMhList(), s));
            }
            if ("IS  - ".equals(name)) {
                text.setIsList(setLastList(text.getIsList(), s));
            }
            if ("PT  - ".equals(name)) {
                text.setPtList(setLastList(text.getPtList(), s));
            }
            if ("RN  - ".equals(name)) {
                text.setRnList(setLastList(text.getRnList(), s));
            }
            if ("OT  - ".equals(name)) {
                text.setOtList(setLastList(text.getOtList(), s));
            }
            if ("LA  - ".equals(name)) {
                text.setLaList(setLastList(text.getLaList(), s));
            }
            if ("PL  - ".equals(name)) {
                text.setPlList(setLastList(text.getPlList(), s));
            }
            if ("LID - ".equals(name)) {
                text.setLidList(setLastList(text.getLidList(), s));
            }
            if ("GR  - ".equals(name)) {
                text.setGrList(setLastList(text.getGrList(), s));
            }
            if ("SI  - ".equals(name)) {
                text.setSiList(setLastList(text.getSiList(), s));
            }
            if ("OID - ".equals(name)) {
                text.setOidList(setLastList(text.getOidList(), s));
            }
            if ("CON - ".equals(name)) {
                text.setConList(setLastList(text.getConList(), s));
            }
            if ("CIN - ".equals(name)) {
                text.setCinList(setLastList(text.getCinList(), s));
            }
            if ("CN  - ".equals(name)) {
                text.setCnList(setLastList(text.getCnList(), s));
            }
            if ("EIN - ".equals(name)) {
                text.setEinList(setLastList(text.getEinList(), s));
            }
            if ("GN  - ".equals(name)) {
                text.setGnList(setLastList(text.getGnList(), s));
            }
            if ("IRAD- ".equals(name)) {
                text.setIradList(setLastList(text.getIradList(), s));
            }
            if ("EFR - ".equals(name)) {
                text.setEfrList(setLastList(text.getEfrList(), s));
            }
            if ("GS  - ".equals(name)) {
                text.setGsList(setLastList(text.getGsList(), s));
            }
            if ("PB  - ".equals(name)) {
                text.setPbList(setLastList(text.getPbList(), s));
            }
            if ("UOF - ".equals(name)) {
                text.setUofList(setLastList(text.getUofList(), s));
            }
            if ("UIN - ".equals(name)) {
                text.setUinList(setLastList(text.getUinList(), s));
            }
            if ("ROF - ".equals(name)) {
                text.setRofList(setLastList(text.getRofList(), s));
            }
            if ("RIN - ".equals(name)) {
                text.setRinList(setLastList(text.getRinList(), s));
            }
            if ("SFM - ".equals(name)) {
                text.setSfmList(setLastList(text.getSfmList(), s));
            }
            if ("ISBN- ".equals(name)) {
                text.setIsbnList(setLastList(text.getIsbnList(), s));
            }
            if ("RPF - ".equals(name)) {
                text.setRpfList(setLastList(text.getRpfList(), s));
            }
            if ("RPI - ".equals(name)) {
                text.setRpiList(setLastList(text.getRpiList(), s));
            }
            if ("ECF - ".equals(name)) {
                text.setEcfList(setLastList(text.getEcfList(), s));
            }
            if ("ECI - ".equals(name)) {
                text.setEciList(setLastList(text.getEciList(), s));
            }
            if ("CRF - ".equals(name)) {
                text.setCrfList(setLastList(text.getCrfList(), s));
            }
            if ("CRI - ".equals(name)) {
                text.setCriList(setLastList(text.getCriList(), s));
            }
            if ("ORI - ".equals(name)) {
                text.setOriList(setLastList(text.getOriList(), s));
            }
            if ("SPIN- ".equals(name)) {
                text.setSpinList(setLastList(text.getSpinList(), s));
            }
            if ("DRIN- ".equals(name)) {
                text.setDrinList(setLastList(text.getDrinList(), s));
            }
            if ("DDIN- ".equals(name)) {
                text.setDdinList(setLastList(text.getDdinList(), s));
            }
            if ("RRF - ".equals(name)) {
                text.setRrfList(setLastList(text.getRrfList(), s));
            }
            if ("STAT- ".equals(name)) {
                text.setStat((text.getStat() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("DP  - ".equals(name)) {
                text.setDp((text.getDp() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("CRDT- ".equals(name)) {
                text.setCrdt((text.getCrdt() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("EDAT- ".equals(name)) {
                text.setEdat((text.getEdat() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("TI  - ".equals(name)) {
                text.setTi((text.getTi() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("SO  - ".equals(name)) {
                text.setSo((text.getSo() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("JT  - ".equals(name)) {
                text.setJt((text.getJt() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("PST - ".equals(name)) {
                text.setPst((text.getPst() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("JID - ".equals(name)) {
                text.setJid((text.getJid() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("LR  - ".equals(name)) {
                text.setLr((text.getLr() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("OWN - ".equals(name)) {
                text.setOwn((text.getOwn() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("MHDA- ".equals(name)) {
                text.setMhda((text.getMhda() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("TA  - ".equals(name)) {
                text.setTa((text.getTa() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("VI  - ".equals(name)) {
                text.setVi((text.getVi() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("PG  - ".equals(name)) {
                text.setPg((text.getPg() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("DCOM- ".equals(name)) {
                text.setDcom((text.getDcom() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("IP  - ".equals(name)) {
                text.setIp((text.getIp() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("SB  - ".equals(name)) {
                text.setSb((text.getSb() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("AB  - ".equals(name)) {
                text.setAb((text.getAb() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("DEP - ".equals(name)) {
                text.setDep((text.getDep() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("OTO - ".equals(name)) {
                text.setOto((text.getOto() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("PMC - ".equals(name)) {
                text.setPmc((text.getPmc() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("PMCR- ".equals(name)) {
                text.setPmcr((text.getPmcr() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("CI  - ".equals(name)) {
                text.setCi((text.getCi() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("COIS- ".equals(name)) {
                text.setCois((text.getCois() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("IR  - ".equals(name)) {
                text.setIr((text.getIr() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("FIR - ".equals(name)) {
                text.setFir((text.getFir() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("TT  - ".equals(name)) {
                text.setTt((text.getTt() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("RF  - ".equals(name)) {
                text.setRf((text.getRf() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("MID - ".equals(name)) {
                text.setMid((text.getMid() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("FPS - ".equals(name)) {
                text.setFps((text.getFps() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("PS  - ".equals(name)) {
                text.setPs((text.getPs() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("OAB - ".equals(name)) {
                text.setOab((text.getOab() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("OABL- ".equals(name)) {
                text.setOabl((text.getOabl() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("FED - ".equals(name)) {
                text.setFed((text.getFed() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("ED  - ".equals(name)) {
                text.setEd((text.getEd() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("BTI - ".equals(name)) {
                text.setBti((text.getBti() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("CTDT- ".equals(name)) {
                text.setCtdt((text.getCtdt() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("CTI - ".equals(name)) {
                text.setCti((text.getCti() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("CP  - ".equals(name)) {
                text.setCp((text.getCp() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("DRDT- ".equals(name)) {
                text.setDrdt((text.getDrdt() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("EN  - ".equals(name)) {
                text.setEn((text.getEn() + " " + s.trim()).replaceAll(" +", " "));
            }
            if ("RRI - ".equals(name)) {
                text.setRriList(setLastList(text.getRriList(), s));
            }
        }
        return name;
    }

    public static void insertNcTextTable(String ncTextTable, List<Text> textList, Set<Integer> pmIdSet) {
        for (Text text : textList) {
            if (!pmIdSet.contains(text.getPmid())) {
                try {
                    Db.use().insert(Entity.create(ncTextTable)
                            .set("aidList", JSONUtil.toJsonStr(text.getAidList()).replaceAll(" +", " "))
                            .set("mhList", JSONUtil.toJsonStr(text.getMhList()).replaceAll(" +", " "))
                            .set("isList", JSONUtil.toJsonStr(text.getIsList()).replaceAll(" +", " "))
                            .set("ptList", JSONUtil.toJsonStr(text.getPtList()).replaceAll(" +", " "))
                            .set("rnList", JSONUtil.toJsonStr(text.getRnList()).replaceAll(" +", " "))
                            .set("otList", JSONUtil.toJsonStr(text.getOtList()).replaceAll(" +", " "))
                            .set("laList", JSONUtil.toJsonStr(text.getLaList()).replaceAll(" +", " "))
                            .set("plList", JSONUtil.toJsonStr(text.getPlList()).replaceAll(" +", " "))
                            .set("lidList", JSONUtil.toJsonStr(text.getLidList()).replaceAll(" +", " "))
                            .set("grList", JSONUtil.toJsonStr(text.getGrList()).replaceAll(" +", " "))
                            .set("siList", JSONUtil.toJsonStr(text.getSiList()).replaceAll(" +", " "))
                            .set("oidList", JSONUtil.toJsonStr(text.getOidList()).replaceAll(" +", " "))
                            .set("conList", JSONUtil.toJsonStr(text.getConList()).replaceAll(" +", " "))
                            .set("cinList", JSONUtil.toJsonStr(text.getCinList()).replaceAll(" +", " "))
                            .set("cnList", JSONUtil.toJsonStr(text.getCnList()).replaceAll(" +", " "))
                            .set("einList", JSONUtil.toJsonStr(text.getEinList()).replaceAll(" +", " "))
                            .set("gnList", JSONUtil.toJsonStr(text.getGnList()).replaceAll(" +", " "))
                            .set("iradList", JSONUtil.toJsonStr(text.getIradList()).replaceAll(" +", " "))
                            .set("efrList", JSONUtil.toJsonStr(text.getEfrList()).replaceAll(" +", " "))
                            .set("gsList", JSONUtil.toJsonStr(text.getGsList()).replaceAll(" +", " "))
                            .set("pbList", JSONUtil.toJsonStr(text.getPbList()).replaceAll(" +", " "))
                            .set("uofList", JSONUtil.toJsonStr(text.getUofList()).replaceAll(" +", " "))
                            .set("uinList", JSONUtil.toJsonStr(text.getUinList()).replaceAll(" +", " "))
                            .set("rofList", JSONUtil.toJsonStr(text.getRofList()).replaceAll(" +", " "))
                            .set("rinList", JSONUtil.toJsonStr(text.getRinList()).replaceAll(" +", " "))
                            .set("sfmList", JSONUtil.toJsonStr(text.getSfmList()).replaceAll(" +", " "))
                            .set("isbnList", JSONUtil.toJsonStr(text.getIsbnList()).replaceAll(" +", " "))
                            .set("rpfList", JSONUtil.toJsonStr(text.getRpfList()).replaceAll(" +", " "))
                            .set("rpiList", JSONUtil.toJsonStr(text.getRpiList()).replaceAll(" +", " "))
                            .set("ecfList", JSONUtil.toJsonStr(text.getEcfList()).replaceAll(" +", " "))
                            .set("eciList", JSONUtil.toJsonStr(text.getEciList()).replaceAll(" +", " "))
                            .set("crfList", JSONUtil.toJsonStr(text.getCrfList()).replaceAll(" +", " "))
                            .set("criList", JSONUtil.toJsonStr(text.getCriList()).replaceAll(" +", " "))
                            .set("oriList", JSONUtil.toJsonStr(text.getOriList()).replaceAll(" +", " "))
                            .set("spinList", JSONUtil.toJsonStr(text.getSpinList()).replaceAll(" +", " "))
                            .set("drinList", JSONUtil.toJsonStr(text.getDrinList()).replaceAll(" +", " "))
                            .set("ddinList", JSONUtil.toJsonStr(text.getDdinList()).replaceAll(" +", " "))
                            .set("rrfList", JSONUtil.toJsonStr(text.getRrfList()).replaceAll(" +", " "))
                            .set("auList", JSONUtil.toJsonStr(text.getAuList()).replaceAll(" +", " "))
                            .set("phstList", JSONUtil.toJsonStr(text.getPhst()).replaceAll(" +", " "))
                            .set("stat", text.getStat().replaceAll(" +", " "))
                            .set("dp", text.getDp().replaceAll(" +", " "))
                            .set("crdt", text.getCrdt().replaceAll(" +", " "))
                            .set("edat", text.getEdat().replaceAll(" +", " "))
                            .set("ti", text.getTi().replaceAll(" +", " "))
                            .set("so", text.getSo().replaceAll(" +", " "))
                            .set("jt", text.getJt().replaceAll(" +", " "))
                            .set("pst", text.getPst().replaceAll(" +", " "))
                            .set("jid", text.getJid().replaceAll(" +", " "))
                            .set("lr", text.getLr().replaceAll(" +", " "))
                            .set("own", text.getOwn().replaceAll(" +", " "))
                            .set("mhda", text.getMhda().replaceAll(" +", " "))
                            .set("ta", text.getTa().replaceAll(" +", " "))
                            .set("pmid", text.getPmid())
                            .set("vi", text.getVi().replaceAll(" +", " "))
                            .set("pg", text.getPg().replaceAll(" +", " "))
                            .set("dcom", text.getDcom().replaceAll(" +", " "))
                            .set("ip", text.getIp().replaceAll(" +", " "))
                            .set("sb", text.getSb().replaceAll(" +", " "))
                            .set("ab", text.getAb().replaceAll(" +", " "))
                            .set("dep", text.getDep().replaceAll(" +", " "))
                            .set("oto", text.getOto().replaceAll(" +", " "))
                            .set("pmc", text.getPmc().replaceAll(" +", " "))
                            .set("pmcr", text.getPmcr().replaceAll(" +", " "))
                            .set("ci", text.getCi().replaceAll(" +", " "))
                            .set("cois", text.getCois().replaceAll(" +", " "))
                            .set("ir", text.getIr().replaceAll(" +", " "))
                            .set("fir", text.getFir().replaceAll(" +", " "))
                            .set("tt", text.getTt().replaceAll(" +", " "))
                            .set("rf", text.getRf().replaceAll(" +", " "))
                            .set("mid", text.getMid().replaceAll(" +", " "))
                            .set("fps", text.getFps().replaceAll(" +", " "))
                            .set("ps", text.getPs().replaceAll(" +", " "))
                            .set("oab", text.getOab().replaceAll(" +", " "))
                            .set("oabl", text.getOabl().replaceAll(" +", " "))
                            .set("fed", text.getFed().replaceAll(" +", " "))
                            .set("ed", text.getEd().replaceAll(" +", " "))
                            .set("bti", text.getBti().replaceAll(" +", " "))
                            .set("ctdt", text.getCtdt().replaceAll(" +", " "))
                            .set("cti", text.getCti().replaceAll(" +", " "))
                            .set("cp", text.getCp().replaceAll(" +", " "))
                            .set("drdt", text.getDrdt().replaceAll(" +", " "))
                            .set("en", text.getEn().replaceAll(" +", " "))
                            .set("rriList", JSONUtil.toJsonStr(text.getRriList()).replaceAll(" +", " "))
                    );
                    pmIdSet.add(text.getPmid());
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public static void fieldNumber() throws SQLException {
        String newDataName = "html.";
        String textFormatTable = newDataName + "text_format_down_pmid";
        String textFormatTable0 = newDataName + "text_format_down_pmid_0";
        String textFormatTable1 = newDataName + "text_format_down_pmid_1";
        String textFormatTable2 = newDataName + "text_format_down_pmid_2";
        String textFormatTable3 = newDataName + "text_format_down_pmid_3";
        String textFormatTable4 = newDataName + "text_format_down_pmid_4";
        String phslFieldSumTable = newDataName + "phsl_field_sum";
        Map<String, Integer> fieldAndSumMap = new HashMap<>();
        Map<String, Integer> infoAndSumMap = new HashMap<>();
        Map<String, Integer> phstAndSumMap = new HashMap<>();
        Map<String, Integer> multipleAndSumMap = new HashMap<>();
        getFieldNumber(textFormatTable, "id", "html", fieldAndSumMap, infoAndSumMap, phstAndSumMap, multipleAndSumMap);
        getFieldNumber(textFormatTable0, "id", "html", fieldAndSumMap, infoAndSumMap, phstAndSumMap, multipleAndSumMap);
        getFieldNumber(textFormatTable1, "id", "html", fieldAndSumMap, infoAndSumMap, phstAndSumMap, multipleAndSumMap);
        getFieldNumber(textFormatTable2, "id", "html", fieldAndSumMap, infoAndSumMap, phstAndSumMap, multipleAndSumMap);
        getFieldNumber(textFormatTable3, "id", "html", fieldAndSumMap, infoAndSumMap, phstAndSumMap, multipleAndSumMap);
        getFieldNumber(textFormatTable4, "id", "html", fieldAndSumMap, infoAndSumMap, phstAndSumMap, multipleAndSumMap);
        Db.use().execute("truncate table " + phslFieldSumTable);
        insertPhslFieldSumTable("m", phslFieldSumTable, multipleAndSumMap);
        insertPhslFieldSumTable("f", phslFieldSumTable, fieldAndSumMap);
        insertPhslFieldSumTable("i", phslFieldSumTable, infoAndSumMap);
        insertPhslFieldSumTable("p", phslFieldSumTable, phstAndSumMap);
    }

    public static void getFieldNumber(String textFormatTable, String autoId, String field, Map<String, Integer> fieldAndSumMap, Map<String, Integer> infoAndSumMap, Map<String, Integer> phstAndSumMap, Map<String, Integer> multipleAndSumMap) throws SQLException {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        int onePageNum = 1000;
        int tableMax = Db.use().queryNumber("select max(" + autoId + ") from " + textFormatTable).intValue();
        if (tableMax > 0) {
            Collection<Integer> tableList = new ArrayList<>();
            NumberUtil.appendRange(0, tableMax + onePageNum, onePageNum, tableList);
            for (Integer startId : tableList) {
                List<Entity> tableData = Db.use().query("select `" + autoId + "`,`" + field + "` from " + textFormatTable + " where " + autoId + " between " + startId + " and " + (startId + onePageNum - 1));
                System.out.println("\033[31;1m" + format.format(new Date()) + " 读表现在开始：" + startId + " 表名：" + textFormatTable + Utils.printMemoryStr() + "\033[0m");
                for (Entity entry : tableData) {
                    byte[] bytes = entry.getBytes("html");
                    if (null != bytes && bytes.length > 0) {
                        String str = ZipUtil.unGzip(bytes, "utf-8");
                        String[] split = str.split(System.lineSeparator());
                        for (int i = 0; i < split.length; i++) {
                            String f = split[i];
                            f = Pattern.compile("PMID- [1-9]").matcher(f).find() ? f.substring(f.indexOf("PMID- ")) : f;
                            String m = (split.length > i + 1) ? split[i + 1] : "";
                            String e = (split.length > i + 2) ? split[i + 2] : "";
                            // 这一类是标准的字段
                            String front = "";
                            if (Pattern.compile("^[A-Z]{2}[A-Z ]{2}- ").matcher(f).find()) {
                                front = f.substring(0, 6);
                                fieldAndSumMap.compute(front, (key, value) -> value != null ? (value + 1) : 1);
                            } else {
                                // 这一种是担心有漏的，凡是开头不为空，且含有"-"，均记录下来人工判断一下。
                                if (!f.startsWith(" ") && f.length() > 10) {
                                    String d = f.substring(0, 10);
                                    if (d.contains("-")) {
                                        if (!infoAndSumMap.containsKey(d)) {
                                            System.out.println("--|" + d + "|--");
                                        }
                                        infoAndSumMap.compute(d, (key, value) -> value != null ? (value + 1) : 1);
                                    }
                                }
                            }
                            // 这一种是同一条记录是否有多条记录
                            if (Pattern.compile("^[A-Z]{2}[A-Z ]{2}- ").matcher(m).find()) {
                                if (front.equals(m.substring(0, 6))) {
                                    multipleAndSumMap.compute(front, (key, value) -> value != null ? (value + 1) : 1);
                                }
                            } else if (m.startsWith(" ") && Pattern.compile("^[A-Z]{2}[A-Z ]{2}- ").matcher(e).find()) {
                                if (front.equals(e.substring(0, 6))) {
                                    multipleAndSumMap.compute(front, (key, value) -> value != null ? (value + 1) : 1);
                                }
                            }
                            // 这个是看一下PHST就有多少种。PHST- 1975/09/01 00:00 [pubmed]、PHST- 1975/09/01 00:01 [medline]、PHST- 1975/09/01 00:00 [entrez]、PHST- 1976/03/01 00:00 [pmc-release]
                            if (f.trim().toLowerCase().startsWith("phst- ")) {
                                Matcher matcher = Pattern.compile("\\[([^\\[\\]]+)]").matcher(f);
                                while (matcher.find()) {
                                    String group = matcher.group(0);
                                    phstAndSumMap.compute(group, (key, value) -> value != null ? (value + 1) : 1);
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    public static void insertPhslFieldSumTable(String type, String phslFieldSumTable, Map<String, Integer> multipleAndSumMap) {
        multipleAndSumMap.keySet().parallelStream().forEach(info -> {
            try {
                Db.use().insert(Entity.create(phslFieldSumTable).set("info", info).set("sum", multipleAndSumMap.get(info)).set("type", type));
            } catch (SQLException e) {
                e.printStackTrace();
            }
        });
    }

    public static Set<String> fieldSet() {
        Set<String> fieldSet = new HashSet<>();
        fieldSet.add("AU  - ");
        fieldSet.add("PHST- ");
        fieldSet.add("AD  - ");
        fieldSet.add("AUID- ");
        fieldSet.add("FAU - ");
        fieldSet.add("AID - ");
        fieldSet.add("MH  - ");
        fieldSet.add("IS  - ");
        fieldSet.add("PT  - ");
        fieldSet.add("RN  - ");
        fieldSet.add("OT  - ");
        fieldSet.add("LA  - ");
        fieldSet.add("PL  - ");
        fieldSet.add("LID - ");
        fieldSet.add("GR  - ");
        fieldSet.add("SI  - ");
        fieldSet.add("OID - ");
        fieldSet.add("CON - ");
        fieldSet.add("CIN - ");
        fieldSet.add("CN  - ");
        fieldSet.add("EIN - ");
        fieldSet.add("GN  - ");
        fieldSet.add("IRAD- ");
        fieldSet.add("EFR - ");
        fieldSet.add("GS  - ");
        fieldSet.add("PB  - ");
        fieldSet.add("UOF - ");
        fieldSet.add("UIN - ");
        fieldSet.add("ROF - ");
        fieldSet.add("RIN - ");
        fieldSet.add("SFM - ");
        fieldSet.add("ISBN- ");
        fieldSet.add("RPF - ");
        fieldSet.add("RPI - ");
        fieldSet.add("ECF - ");
        fieldSet.add("ECI - ");
        fieldSet.add("CRF - ");
        fieldSet.add("CRI - ");
        fieldSet.add("ORI - ");
        fieldSet.add("SPIN- ");
        fieldSet.add("DRIN- ");
        fieldSet.add("DDIN- ");
        fieldSet.add("RRF - ");
        fieldSet.add("STAT- ");
        fieldSet.add("DP  - ");
        fieldSet.add("CRDT- ");
        fieldSet.add("EDAT- ");
        fieldSet.add("TI  - ");
        fieldSet.add("SO  - ");
        fieldSet.add("JT  - ");
        fieldSet.add("PST - ");
        fieldSet.add("JID - ");
        fieldSet.add("LR  - ");
        fieldSet.add("OWN - ");
        fieldSet.add("MHDA- ");
        fieldSet.add("TA  - ");
        fieldSet.add("VI  - ");
        fieldSet.add("PG  - ");
        fieldSet.add("DCOM- ");
        fieldSet.add("IP  - ");
        fieldSet.add("SB  - ");
        fieldSet.add("AB  - ");
        fieldSet.add("DEP - ");
        fieldSet.add("OTO - ");
        fieldSet.add("PMC - ");
        fieldSet.add("PMCR- ");
        fieldSet.add("CI  - ");
        fieldSet.add("COIS- ");
        fieldSet.add("IR  - ");
        fieldSet.add("FIR - ");
        fieldSet.add("TT  - ");
        fieldSet.add("RF  - ");
        fieldSet.add("MID - ");
        fieldSet.add("FPS - ");
        fieldSet.add("PS  - ");
        fieldSet.add("OAB - ");
        fieldSet.add("OABL- ");
        fieldSet.add("FED - ");
        fieldSet.add("ED  - ");
        fieldSet.add("BTI - ");
        fieldSet.add("CTDT- ");
        fieldSet.add("CTI - ");
        fieldSet.add("CP  - ");
        fieldSet.add("DRDT- ");
        fieldSet.add("EN  - ");
        fieldSet.add("RRI - ");
        return fieldSet;
    }


    @Data
    public static class Text implements Serializable {
        private static final long serialVersionUID = 1L;
        private List<String> aidList = new ArrayList<>();
        private List<String> mhList = new ArrayList<>();
        private List<String> isList = new ArrayList<>();
        private List<String> ptList = new ArrayList<>();
        private List<String> rnList = new ArrayList<>();
        private List<String> otList = new ArrayList<>();
        private List<String> laList = new ArrayList<>();
        private List<String> plList = new ArrayList<>();
        private List<String> lidList = new ArrayList<>();
        private List<String> grList = new ArrayList<>();
        private List<String> siList = new ArrayList<>();
        private List<String> oidList = new ArrayList<>();
        private List<String> conList = new ArrayList<>();
        private List<String> cinList = new ArrayList<>();
        private List<String> cnList = new ArrayList<>();
        private List<String> einList = new ArrayList<>();
        private List<String> gnList = new ArrayList<>();
        private List<String> iradList = new ArrayList<>();
        private List<String> efrList = new ArrayList<>();
        private List<String> gsList = new ArrayList<>();
        private List<String> pbList = new ArrayList<>();
        private List<String> uofList = new ArrayList<>();
        private List<String> uinList = new ArrayList<>();
        private List<String> rofList = new ArrayList<>();
        private List<String> rinList = new ArrayList<>();
        private List<String> sfmList = new ArrayList<>();
        private List<String> isbnList = new ArrayList<>();
        private List<String> rpfList = new ArrayList<>();
        private List<String> rpiList = new ArrayList<>();
        private List<String> ecfList = new ArrayList<>();
        private List<String> eciList = new ArrayList<>();
        private List<String> crfList = new ArrayList<>();
        private List<String> criList = new ArrayList<>();
        private List<String> oriList = new ArrayList<>();
        private List<String> spinList = new ArrayList<>();
        private List<String> drinList = new ArrayList<>();
        private List<String> ddinList = new ArrayList<>();
        private List<String> rrfList = new ArrayList<>();
        private List<AU> auList = new ArrayList<>();
        private PHST phst = new PHST();
        private String stat = "";
        private String dp = "";
        private String crdt = "";
        private String edat = "";
        private String ti = "";
        private String so = "";
        private String jt = "";
        private String pst = "";
        private String jid = "";
        private String lr = "";
        private String own = "";
        private String mhda = "";
        private String ta = "";
        private int pmid = 0;
        private String vi = "";
        private String pg = "";
        private String dcom = "";
        private String ip = "";
        private String sb = "";
        private String ab = "";
        private String dep = "";
        private String oto = "";
        private String pmc = "";
        private String pmcr = "";
        private String ci = "";
        private String cois = "";
        private String ir = "";
        private String fir = "";
        private String tt = "";
        private String rf = "";
        private String mid = "";
        private String fps = "";
        private String ps = "";
        private String oab = "";
        private String oabl = "";
        private String fed = "";
        private String ed = "";
        private String bti = "";
        private String ctdt = "";
        private String cti = "";
        private String cp = "";
        private String drdt = "";
        private String en = "";
        private List<String> rriList = new ArrayList<>();
    }

    @Data
    public static class AU implements Serializable {
        private static final long serialVersionUID = 1L;
        private String fau = "";
        private String au = "";
        private String auid = "";
        private List<String> adList = new ArrayList<>();
    }

    @Data
    public static class PHST implements Serializable {
        private static final long serialVersionUID = 1L;
        private String revised = "";
        private String pubmed = "";
        private String ecollection = "";
        private String aheadofprint = "";
        private String accepted = "";
        private String received = "";
        private String retracted = "";
        private String medline = "";
        private String entrez = "";
        private String pmcRelease = "";
    }

    /*
      CREATE TABLE `nc_text_table` (
        `id` int(10) NOT NULL AUTO_INCREMENT,
        `aidList` longtext,
        `mhList` longtext,
        `isList` longtext,
        `ptList` longtext,
        `rnList` longtext,
        `otList` longtext,
        `laList` longtext,
        `plList` longtext,
        `lidList` longtext,
        `grList` longtext,
        `siList` longtext,
        `oidList` longtext,
        `conList` longtext,
        `cinList` longtext,
        `cnList` longtext,
        `einList` longtext,
        `gnList` longtext,
        `iradList` longtext,
        `efrList` longtext,
        `gsList` longtext,
        `pbList` longtext,
        `uofList` longtext,
        `uinList` longtext,
        `rofList` longtext,
        `rinList` longtext,
        `sfmList` longtext,
        `isbnList` longtext,
        `rpfList` longtext,
        `rpiList` longtext,
        `ecfList` longtext,
        `eciList` longtext,
        `crfList` longtext,
        `criList` longtext,
        `oriList` longtext,
        `spinList` longtext,
        `drinList` longtext,
        `ddinList` longtext,
        `rrfList` longtext,
        `auList` longtext,
        `phstList` longtext,
        `stat` text,
        `dp` text,
        `crdt` text,
        `edat` text,
        `ti` text,
        `so` text,
        `jt` text,
        `pst` text,
        `jid` text,
        `lr` text,
        `own` text,
        `mhda` text,
        `ta` text,
        `pmid` int(8) DEFAULT NULL,
        `vi` text,
        `pg` text,
        `dcom` text,
        `ip` text,
        `sb` text,
        `ab` text,
        `dep` text,
        `oto` text,
        `pmc` text,
        `pmcr` text,
        `ci` text,
        `cois` text,
        `ir` text,
        `fir` text,
        `tt` text,
        `rf` text,
        `mid` text,
        `fps` text,
        `ps` text,
        `oab` text,
        `oabl` text,
        `fed` text,
        `ed` text,
        `bti` text,
        `ctdt` text,
        `cti` text,
        `cp` text,
        `drdt` text,
        `en` text,
        `rriList` longtext,
        PRIMARY KEY (`id`),
        KEY `pmid` (`pmid`)
      ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
     */


}
